import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.XPath;

import java.io.IOException;

/**
 * @author ml
 * @create 2017-07-29--12:32
 */
public class PFFrame_flex {

    private String basePath;
    private String serverIp;
    public PFFrame_flex(String bathpath,String serverIp){
        this.basePath=bathpath;
        this.serverIp=serverIp;

    }

    public void changexml() throws Exception{
        Document doc=XmlUtil.parse(basePath+FilePathEnum.PFFRAME_FLEX.getValue());
        updateDocByXPATH(doc);

    }

    public void updateDocByXPATH(Document doc) throws DocumentException, IOException {

        XPath datapath=doc.createXPath("//appServer");


        Element dataelement= (Element) datapath.selectSingleNode(doc);

        dataelement.setText("http://"+serverIp+":8080/AppServer/messagebroker/amf");



        XPath usernamepath=doc.createXPath("//dynformServer");


        Element usernameelement= (Element) usernamepath.selectSingleNode(doc);

        usernameelement.setText("http://"+serverIp+":8080/AppServer/DynFormView");






        XmlUtil.saveDocument(doc,basePath+FilePathEnum.PFFRAME_FLEX.getValue());







    }
}
